package com.jdls.tanhua.dubbo.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jdls.tanhua.dubbo.UserApi;
import com.jdls.tanhua.dubbo.mapper.UserMapper;
import com.jdls.tanhua.pojo.User;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author 嘉德罗斯
 * @date 2021/10/22
 */
//暴露服务
@DubboService
public class UserApiImpl implements UserApi {

    @Autowired
    private UserMapper userMapper;
    @Override
    public User findPhone(String phone) {
        LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(User::getMobile,phone);
        User user = userMapper.selectOne(queryWrapper);
        return user;
    }

    @Override
    public Long save(User user) {
        userMapper.insert(user);
        return user.getId();
    }

    @Override
    public void update(User user) {
        userMapper.updateById(user);
    }

    @Override
    //环信用户信息
    public User findId(Long id) {
        LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(User::getId,id);
        User user = userMapper.selectOne(queryWrapper);
        return user;
    }
}
